"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Room_1 = __importDefault(require("../models/Room"));
const Hall_1 = __importDefault(require("../models/Hall"));
async function default_1(call) {
    const { player, password } = call.req;
    let conn = Hall_1.default.instance.get(player.openid);
    if (!conn) {
        conn = Hall_1.default.instance.connect(player.openid, call.conn);
        // call.error("创建失败, 已断开连接")
        // return
    }
    if (!Room_1.default.instance.canCreate()) {
        call.error("创建失败, 房间数已满");
        return;
    }
    const room = Room_1.default.instance.create(player, password);
    call.succ({ room });
}
exports.default = default_1;
